package com.yk.business;

import com.yk.client.Loader;
import com.yk.clienthandler.MessageSendHandler;

import java.lang.reflect.Proxy;

/**
 * Created by dingkl on 2017/7/28.
 */
public class CreateInstance {

    private MessageSendHandler messageSendHandler;

    private Loader loader = Loader.loader();

    public CreateInstance(String host,int port){
        loader.load(host,port);
    }

    public void close(){
        loader.close();
    }

    public <T> T getInstance(Class<T> tClass)throws Exception{
        return (T)Proxy.newProxyInstance(tClass.getClassLoader(),new Class<?>[]{tClass},new ProxyHandler());
    }

}
